import java.util.concurrent.CountDownLatch;

public class Demo5 {
    public static void main(String[] args) throws InterruptedException {
        CountDownLatch countDownLatch = new CountDownLatch(5);
        for (int i = 0; i < 5 ; i++) {
            int temp = i;
            Thread t = new Thread(()->{
                System.out.println("线程 "+ temp +"执行");
                countDownLatch.countDown();
            });
            t.start();
        }
        //等待所有线程结束
        countDownLatch.await();
        System.out.println("所有线程直接结束");
    }
}
